package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;

public class BankApplication {
    public static void main(String[] args) {
        Bank bank = createArbitraryBank();
        new BankService().modifyBank(bank);
    }

    private static Bank createArbitraryBank() {
        List<ClientRegistrationListener> listeners = new LinkedList<ClientRegistrationListener>();
        listeners.add(new Bank.PrintClientListener());
        listeners.add(new Bank.EmailNotificationListener());
        Bank bank = new Bank(listeners);
        Random random = new Random();
        int numberOfClients = random.nextInt(10);
        for (int i = 0; i < numberOfClients; i++) {
            Gender gender = i % 2 == 0 ? Gender.MALE : Gender.FEMALE;
            Client client = new Client("Client" + i, gender);
            client.addAccount(new SavingAccount(random.nextInt(100)));
            client.addAccount(new CheckingAccount(random.nextInt(100), random.nextInt(100)));
            bank.addClient(client);
        }
        return bank;
    }
}